<template>
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button
          style="float: right"
          @click="handleSearchList()"
          type="primary"
          size="small">
          查询结果
        </el-button>
        <el-button
          style="float: right;margin-right: 15px"
          @click="handleResetSearch()"
          size="small">
          重置
        </el-button>
      </div>
      <div style="margin-top: 15px">
        <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
          <el-form-item label="姓名：">
            <el-input style="width: 203px" v-model="listQuery.name" placeholder="姓名"></el-input>
          </el-form-item>
          <el-form-item label="手机号：">
            <el-input style="width: 203px" v-model="listQuery.phone" placeholder="手机号"></el-input>
          </el-form-item>


        </el-form>
      </div>
    </el-card>
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
      <el-button
        class="btn-add"
        @click="handleAddProduct()"
        size="mini">
        添加
      </el-button>
    </el-card>
    <div class="table-container">
      <el-table ref="productTable"
                :data="list"
                v-loading="loading"
                style="width: 100%"
                @selection-change="handleSelectionChange"
                border>
        <el-table-column type="selection" width="60" align="center"></el-table-column>
        <el-table-column label="用户名"  align="center">
          <template slot-scope="scope">{{scope.row.username}}</template>
        </el-table-column>
        <el-table-column label="手机号"  align="center">
          <template slot-scope="scope">{{scope.row.phone}}</template>
        </el-table-column>
        <el-table-column label="邮箱" align="center">
          <template slot-scope="scope">
            <p>{{scope.row.email}}</p>
          </template>
        </el-table-column>


        <el-table-column label="审核状态" width="100" align="center">
          <template slot-scope="scope">
            <p>{{scope.row.status | verifyStatusFilter}}</p>
            <p>
              <el-button type="text"  > 审核详情 </el-button>
            </p>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="160" align="center">
          <template slot-scope="scope">
            <p>
              <el-button size="mini" >查看 </el-button>
              <el-button size="mini">编辑 </el-button>
            </p>

          </template>
        </el-table-column>
      </el-table>
    </div>

    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :page-size="listQuery.pageSize"
        :page-sizes="[5,10,15]"
        :current-page.sync="listQuery.pageNum"
        :total="total">
      </el-pagination>
    </div>

  </div>
</template>

<script>
  import {fetchList} from "@/static/api/admin"
    export default {
      name: "adminList",
      data(){
        return {
          loading: false,
          listQuery: Object.assign({},defaultListQuery),
          total:0,
          list: null
        }
      },
      created:function (){
        //初始化列表
        this.handleSearchList()
      },
      methods:{
        handleSearchList(){
          this.loading = true;
          fetchList(this.listQuery).then(response => {
            this.loading = false;
            this.list = response.data.list;
            this.total = response.data.total;
          });
        },
        handleResetSearch(){
          console.info("重置")
        },
        handleAddProduct(){
          console.info("重置")
        },
        handleSelectionChange(){

        },
        handleCurrentChange(){

        },
        handleSizeChange(){

        }
      },
      filters:{
        verifyStatusFilter(value) {
          if (value === 1) {
            return '审核通过';
          } else {
            return '未审核';
          }
        }
      }
    }

    const defaultListQuery = {
      name: null,
      phone:null,
      pageNum: 1,
      pageSize: 5
    };
</script>

<style scoped>

</style>
